#!/bin/bash

ps -eaf | grep send_message.py | grep -v grep
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
python -O /root/get_message/send_message.py &
echo `date "+%G-%m-%d %H:%M:%S"`" send_message            restart"
echo "------------------------------------------------------------------------"
else
echo `date "+%G-%m-%d %H:%M:%S"`" send_message            running"
echo "------------------------------------------------------------------------"
fi

ps -eaf | grep get_ip.py | grep -v grep
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
python /root/get_message/get_ip.py
echo `date "+%G-%m-%d %H:%M:%S"`" get_ip            restart"
echo "------------------------------------------------------------------------"
else
echo `date "+%G-%m-%d %H:%M:%S"`" get_ip            running"
echo "------------------------------------------------------------------------"
fi



FILE_PATH="/root/get_message/UUID"
if [ -f "$FILE_PATH" ]; then
    echo "$FILE_PATH exists. Content of the file:"
    ps -eaf | grep adsb-setting |grep -v grep
    if [ $? -eq 1 ]
    then
        /usr/local/bin/adsb-setting -d -share
        echo `date "+%G-%m-%d %H:%M:%S"`" adsb-setting  start"
        echo "------------------------------------------------------------------------"
    else
        echo `date "+%G-%m-%d %H:%M:%S"`" adsb-setting  running"
        echo "------------------------------------------------------------------------"
    fi
fi
